package org.example.spring_frist.NumberProject.server;

import org.example.spring_frist.NumberProject.dao.numberDao;

public class calcServer {
    public static String sum(Integer num1, Integer num2) {
        if (num1 == null || num2 == null) {
            return "<h1>error</h1><br>";
        }
        return "<h1> 计算结果 " + (num1 + num2) + "</h1><br>";
    }

    public static String sumByJson(numberDao n1) {
        try {
            int sum = Integer.parseInt(n1.getN1().toString()) + Integer.parseInt(n1.getN2().toString());
            return Integer.toString(sum);
        } catch (NumberFormatException e) {
            return null;
        }
    }
}
